<?php
/*
Template Name: Guestbook
*/
?>
<?php
function addHeaderCode() {
    echo '<link type="text/css" rel="stylesheet" href="'.get_bloginfo('wpurl').'/wp-content/plugins/wp-livechat/style/ajaxchat.css">'."\n";
}
add_action('wp_head','addHeaderCode');

wp_enqueue_script('jquery',
get_bloginfo('wpurl').'/wp-includes/js/jquery/jquery.js');
// import the ajax js
//wp_enqueue_script('newscript',get_bloginfo('wpurl').'/wp-content/plugins/wp-livechat/js/jq_ajax_chat.js.php');
// import jquery libary
wp_enqueue_script('livechat',
get_bloginfo('wpurl').'/wp-content/plugins/wp-livechat/js/ajaxchat.js.php');

// Get room list
$sql="select * from `wp_chatroom` ";
$wp_rooms=$wpdb->get_results($sql);

// Get the user list
$sql="Select * from `wp_users`";
$wp_users=$wpdb->get_results($sql);

$current_info=wp_get_current_user();

$current_id=$current_info->id;

?>

<?php get_header(); ?>

	<div id="main">
    	<div id="tab">
            	<div class="tab1"></div>
                <div id="tag1" class="tag-selected" onclick="tab('1');"><img src="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/session.gif" width="59" height="16" /></div>
                <div class="tab2"></div>
                <div id="tag2" onclick="tab('2');"><img src="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/private.gif" width="78" height="16" /></div>
                <div class="tab3"></div>
		</div>
        <div id="box1">
            <form id="sender_form">
        	<div class="title">
           	  <h2><img src="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/label.gif" width="166" height="18" /></h2>
                <select name="chat_room_id" size="1">
                    <?php foreach($wp_rooms as $room): ?>
                <option value="<?php echo $room->chat_room_id ?>"><?php echo $room->title ?></option>
                    <?php endforeach; ?>
                </select>
                <label for="channel">Choose Channel:</label>
            </div>
              <textarea id="message" name="message" onkeydown="session_key_down(event);" cols="" rows=""></textarea>
              <input name="session_btn" type="button" value="" onclick="jq_insert_message(); return false" />
            </form>
			<br class="clear" />
            <div class="content">

            	<ul id="messageContent">
                <li>
                </li>
                </ul>

            </div>
        </div>

        <div id="box2" style="display:none;">
        <form id="private_form">
        <div class="title">
           	  <h2><img src="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/label.gif" width="166" height="18" /></h2>
                <select id="receiver_id" name="receiver_id" size="1">
                    <?php
                    foreach($wp_users as $user)
                    {
                        if($user->ID!=$current_id)
                        {
                            echo '<option value="'.$user->ID.'">'.$user->display_name.'</option>';
                        }
                    }
                    ?>
              </select>
              <label  for="private_message">Choose User:</label>
            </div>
            	<textarea id="private_message" name="private_message" onkeydown="private_key_down(event);" cols="" rows=""></textarea>
           	  <input name="but2" type="button" value="" onclick="private_ajax_chat(); return false" />
            </form>
			<br class="clear"/>
            <div class="content">
            	<ul id="private_messageContent">
                </ul>
            </div>
        </div>
    </div>
  <div id="sidebar">
   	<div id="side_top">
	<img src="<?php echo get_bloginfo('wpurl') ?>/wp-content/plugins/wp-livechat/style/img/side.gif" width="184" height="139" /></div>
      <ul id="list">
        <?php foreach($wp_rooms as $room): ?>
            <li style="background-color:#<?php echo $room->color; ?>">
                <input type="checkbox" id="room" alt="<?php echo $room->chat_room_id; ?>" name="<?php echo $room->chat_room_id; ?>" onclick="hideMess(this.alt);" checked="checked" />
                <div class="info2">
                    <label for="<?php echo $room->chat_room_id; ?>"><?php echo $room->title ?></label>
                    <span>Start on <?php echo date('F j, Y, g:i A',mktime($room->timestamp)) ?></span>
                </div>
            </li>
        <?php endforeach; ?>
        <?php
        /*
       	  <li>
          	<input type="checkbox" />
            <div class="info2">
            	<p>Romani conversa signa bipertito intulerunt.</p>
                <span>Start on Jan 10,2009 06:35 PM</span>
            </div>
        </li>
        */
        ?>
    </ul>
    <div id="m_calendar">
    <?php
        include_once dirname(dirname(dirname(__FILE__))).'/plugins/wp-livechat/calendar.php';
    ?>
    </div>

  </div>


<?php get_footer(); ?>
